@extends('backend.template.bootstrap')
@section('content')
@include('UEditor::head')
<div class="m-b-md">
	<h3 class="m-b-none">小说管理</h3>
</div>
<div class="row">
	<div class="col-lg-12">
		<ul class="breadcrumb">
			<li><a href="{{ url('backend') }}"><i class="fa fa-home"></i> 首页</a></li>
			<li><a href="{{ url('backend/books') }}">小说管理</a></li>
			<li><a href="{{ url('backend/books/'.$book->id.'/sections') }}">小说管理</a></li>
			<li class="active">编辑章节</li>
		</ul>
	</div>
</div>
@if (Session::has('msg'))
<div class="alert alert-dismissable alert-danger">
	<button type="button" class="close" data-dismiss="alert">×</button>
	<strong>消息提示：</strong> {{ Session::get('msg') }}
</div>
@elseif ($errors->any())
<div class="alert alert-danger" role="alert">
	<button type="button" class="close" data-dismiss="alert">×</button>
	<strong>消息提示：</strong> {{ $errors->first() }}
</div>
@endif
<section class="panel panel-default">
	<header class="panel-heading font-bold">
		编辑章节
	</header>
	<div class="panel-body">
		{!! Form::model($book, array('method' => 'PATCH', 'route' => array('books.sections.update', $book->id, $section->id), 'files' => true)) !!}
			<div class="form-group">
				{!! Form::label('book_name', '小说名称', array('class' => 'control-label')) !!}
				<div class="form-control">{{ $section->book->name }}</div>
			</div>
			<div class="form-group">
				{!! Form::label('name', '章节名称', array('class' => 'control-label')) !!}
				{!! Form::text('name', $section->name, array('class' => 'form-control')) !!}
			</div>
			<div class="form-group">
				{!! Form::label('content', '章节内容', array('class' => 'control-label')) !!}
				<script id="ueditor" name="content" type="text/plain">{!! $section->content !!}</script>
			</div>
			<div class="form-group">
				{!! Form::label('order', '排序', array('class' => 'control-label')) !!}
				{!! Form::text('order', $section->order, array('class' => 'form-control')) !!}
			</div>
	  		<div class="form-group">
  				<button type="submit" class="btn btn-primary">
  					立即保存
  				</button>
				<a href="{{ url('backend/books') }}" class="btn btn-default">返回</a>
	  		</div>
		{!! Form::close() !!}
	</div>
</section>
<script id="ueditor"></script>
<script>
    var ue=UE.getEditor("ueditor");
    ue.ready(function(){
         //因为Laravel有防csrf防伪造攻击的处理所以加上此行
         ue.execCommand('serverparam','_token','{{ csrf_token() }}');
    });
</script>
@stop